import java.net.*;
import java.io.*;

public class Server2
{
	public static void main(String [] args) throws IOException
	{
		ServerSocket serverSocket = null;
		String data = "Hello, world";

		try{
			serverSocket = new ServerSocket(1234);
			System.out.println("Server listening");
		}catch(IOException e){
			System.err.println("Could not listen on port 1234");
			System.exit(1);
		}

		Socket clientSocket = null;
		while(true){
		try{
			clientSocket = serverSocket.accept();	
			PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
			out.println(data);
			out.close();
		}catch(IOException e){
			System.err.println("Accept failed");
			System.exit(1);
		}
	
		clientSocket.close();
		//serverSocket.close();
		}
	}
}